﻿@{
    Layout = null;
}
@model System.Collections.IEnumerable
<!DOCTYPE html>

<html>
@Html.Partial("LoadPanelPartial")
<head>
  @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
    }
    <link href="@Url.Content("~/Content/Site.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>
    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>
    
    @Html.DevExpress().GetStyleSheets(

                new StyleSheet { ExtensionType = ExtensionType.GridView, Theme = DevExpressHelper.Theme }

)
    @Html.DevExpress().GetScripts(
                    new Script { ExtensionType = ExtensionType.ListBox }
    )

    <script type="text/javascript">
        $(function () {
            $("#toolMenu").smartFloat();
        });

        function OnBeginCallback(s, e) {
            e.customArgs["command"] = e.command;
            e.customArgs["pageIndex"] = s.pageIndex;
            e.customArgs["pageCount"] = s.pageCount;
            e.customArgs["pageRowSize"] = s.pageRowSize;
            e.customArgs["pageRowCount"] = s.pageRowCount;
            e.customArgs["Type"] = $('#hidType').val();
            e.customArgs["gNO"] = $('#hidgNO').val();
            e.customArgs["DutyNo"] = $('#hidDutyNo').val();
        }


        function MenuTop_emClick(source, e) {
            switch (e.item.name) {
                case "btnAdd":
                    {
                        //增加
                        window.location.href = rootPath + "/Admin/Group/GroupEmplEdit?gNO=" + $('#hidgNO').val();
                        break;
                    }
                case "btnDelete":
                    {
                        //删除
                        GroupManyDel();
                        break;
                    }
            }
        }

        function GetSelectedFieldValuesCallback(values) {
            var FEmplNoArr = "";
            var FWorkGrpNoArr = "";
            for (var i = 0; i < values.length; i++) {
                if (FEmplNoArr != "") {
                    FWorkGrpNoArr += "," + values[i][0];
                    FEmplNoArr += "," + values[i][1];
                }
                else {
                    FWorkGrpNoArr += values[i][0];
                    FEmplNoArr += values[i][1];
                }
            }
            if (FWorkGrpNoArr == "") {
                alert("请选择需要删除的人员!");
            }
            else {
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/Group/EmplManyDel',
                    data: { FWorkGrpNoArr: FWorkGrpNoArr, FEmplNoArr: FEmplNoArr },
                    success: function (result) {
                        if (result == "ok") {
                            alert("删除成功!");
                            gvGroup.Refresh();
                        } else if (result == "error") {
                            alert("删除失败!");
                        } else {
                            alert("删除参数错误!");
                        }
                    }
                });
            }

        }

     
        //批量删除
        function GroupManyDel() {
            gvGroup.GetSelectedFieldValues("FWorkGrpNo;FEmplNo", GetSelectedFieldValuesCallback);

        }

        //编辑
        function GroupEmpEdit(FWorkGrpNo, FEmplNo) {
            window.location.href = rootPath + "/Admin/Group/GroupEmplEdit?gNo=" + FWorkGrpNo + "&FEmplNO=" + FEmplNo;
        }

        //删除
        function GroupEmpDel(FWorkGrpNo, FEmplNo){
            if (confirm("确定删除")) {
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/Group/DelGroupEmpl',
                    data: { FWorkGrpNo: FWorkGrpNo, FEmplNo: FEmplNo },
                    success: function (result) {
                        if (result == "ok") {
                            alert("删除成功!");
                            gvGroup.Refresh();
                        } else if (result == "error") {
                            alert("删除失败!");
                        } else {
                            alert("删除参数错误!");
                        }
                    }
                });
            }
        }

    </script>

</head>
<body>
 <div class="floatToolMenu" id="toolMenu">
        @Html.DevExpress().Menu(settings =>
       {
           settings.Name = "toolBarMenu";
           settings.ItemAutoWidth = false;
           settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
           settings.Styles.Style.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
           settings.Styles.Style.BorderTop.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);

           settings.Items.Add(item =>
           {
               item.Name = "btnAdd";
               item.Text = "增加";
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/edit_add.png");

           });
           settings.Items.Add(item =>
           {
               item.Name = "btnDelete";
               item.Text = "删除";
               item.ItemStyle.ForeColor = System.Drawing.Color.Red;
               item.ClientEnabled = true;
               item.Image.Url = Url.Content("~/Content/ControlImages/cancel.png");

           });
           settings.ClientSideEvents.ItemClick = "function(source,e){MenuTop_emClick(source,e)}";
           settings.ItemLinkMode = ItemLinkMode.ContentBounds;
       }).GetHtml()
    </div>
    @Html.Partial("GroupEmplListPartial", Model)
    @Html.Hidden("hidType", ViewData["type"])
    @Html.Hidden("hidgNO", ViewData["gNO"])
    @Html.Hidden("hidDutyNo", ViewData["dutyNo"])

     <script>
         lp.Hide();
    </script>
</body>
</html>
